<?php


	require_once( PATH_FRAMEWORK_LIBRARY
				._SEPARATOR_SO
				.'bm'
				._SEPARATOR_SO
				.'exception'
				._SEPARATOR_SO
				.'IException.class.php');
				
	require_once( PATH_FRAMEWORK_LIBRARY
				._SEPARATOR_SO
				.'bm'
				._SEPARATOR_SO
				.'exception'
				._SEPARATOR_SO
				.'CustonException.class.php');
	
	require_once( PATH_FRAMEWORK_LIBRARY
				._SEPARATOR_SO
				.'bm'
				._SEPARATOR_SO
				.'exception'
				._SEPARATOR_SO
				.'AppException.class.php');

function ReformatCSVString($strInput)
{ 
 
        // Replace accented characters 
        $strInput = str_replace("\u00c0", "À", $strInput);
        $strInput = str_replace("\u00c1", "Á", $strInput);
        $strInput = str_replace("\u00c2", "Â", $strInput);
        $strInput = str_replace("\u00c3", "Ã", $strInput);
        $strInput = str_replace("\u00c4", "Ä", $strInput);
        $strInput = str_replace("\u00c5", "Å", $strInput);
        $strInput = str_replace("\u00c6", "Æ", $strInput);
        $strInput = str_replace("\u00c7", "Ç", $strInput);
        $strInput = str_replace("\u00c8", "È", $strInput);
        $strInput = str_replace("\u00c9", "É", $strInput);
        $strInput = str_replace("\u00ca", "Ê", $strInput);
        $strInput = str_replace("\u00cb", "Ë", $strInput);
        $strInput = str_replace("\u00cc", "Ì", $strInput);
        $strInput = str_replace("\u00cd", "Í", $strInput);
        $strInput = str_replace("\u00ce", "Î", $strInput);
        $strInput = str_replace("\u00cf", "Ï", $strInput);
        $strInput = str_replace("\u00d1", "Ñ", $strInput);
        $strInput = str_replace("\u00d2", "Ò", $strInput);
        $strInput = str_replace("\u00d3", "Ó", $strInput);
        $strInput = str_replace("\u00d4", "Ô", $strInput);
        $strInput = str_replace("\u00d5", "Õ", $strInput);
        $strInput = str_replace("\u00d6", "Ö", $strInput);
        $strInput = str_replace("\u00d8", "Ø", $strInput);
        $strInput = str_replace("\u00d9", "Ù", $strInput);
        $strInput = str_replace("\u00da", "Ú", $strInput);
        $strInput = str_replace("\u00db", "Û", $strInput);
        $strInput = str_replace("\u00dc", "Ü", $strInput);
        $strInput = str_replace("\u00dd", "Ý", $strInput);
 
        //Now lower case accents 		
        $strInput = str_replace("\u00df", "ß", $strInput);
        $strInput = str_replace("\u00e0", "à", $strInput);
        $strInput = str_replace("\u00e1", "á", $strInput);
        $strInput = str_replace("\u00e2", "â", $strInput);
        $strInput = str_replace("\u00e3", "ã", $strInput);
        $strInput = str_replace("\u00e4", "ä", $strInput);
        $strInput = str_replace("\u00e5", "å", $strInput);
        $strInput = str_replace("\u00e6", "æ", $strInput);
        $strInput = str_replace("\u00e7", "ç", $strInput);
        $strInput = str_replace("\u00e8", "è", $strInput);
        $strInput = str_replace("\u00e9", "é", $strInput);
        $strInput = str_replace("\u00ea", "ê", $strInput);
        $strInput = str_replace("\u00eb", "ë", $strInput);
        $strInput = str_replace("\u00ec", "ì", $strInput);
        $strInput = str_replace("\u00ed", "í", $strInput);
        $strInput = str_replace("\u00ee", "î", $strInput);
        $strInput = str_replace("\u00ef", "ï", $strInput);
        $strInput = str_replace("\u00f0", "ð", $strInput);
        $strInput = str_replace("\u00f1", "ñ", $strInput);
        $strInput = str_replace("\u00f2", "ò", $strInput);
        $strInput = str_replace("\u00f3", "ó", $strInput);
        $strInput = str_replace("\u00f4", "ô", $strInput);
        $strInput = str_replace("\u00f5", "õ", $strInput);
        $strInput = str_replace("\u00f6", "ö", $strInput);
        $strInput = str_replace("\u00f8", "ø", $strInput);
        $strInput = str_replace("\u00f9", "ù", $strInput);
        $strInput = str_replace("\u00fa", "ú", $strInput);
        $strInput = str_replace("\u00fb", "û", $strInput);
        $strInput = str_replace("\u00fc", "ü", $strInput);
        $strInput = str_replace("\u00fd", "ý", $strInput);
        $strInput = str_replace("\u00ff", "ÿ", $strInput);
 
        return $strInput; 
 
 }

function showAppException( $e ){
	
	ob_start();
	ob_end_clean();	
	ob_start();
	
	header('Content-type: text/json; charset=utf-8');
	
	$result=array("status"=>0,
					"data"=>$e->getMessage(),//ReformatCSVString($e->getMessage()),//mb_convert_encoding($e->getMessage(), "UTF-8", "ISO-8859-1"),
					"notification"=>-1);
									
	echo  ReformatCSVString(json_encode($result)); 					
	exit();
								
	/*echo '<div>'
		.'Trace:<br>'
		.$e->getTraceAsString()
		.'<br>File:<br>'
		.$e->getFile()
		.'<br>Code:<br>'
		.$e->getCode()
		.'<br>Line:<br>'
		.$e->getLine()
		.'<br>Message:<br>'
		.$e->getMessage()
		.'</div>';
		*/
		
	// //exit();
}

?>